CROSS_COMPILE 	?= 
TARGET		  	?= minilzo
BUILD_DIR        = build
CC 				:= $(CROSS_COMPILE)gcc
LD				:= $(CROSS_COMPILE)ld
OBJCOPY 		:= $(CROSS_COMPILE)objcopy
OBJDUMP 		:= $(CROSS_COMPILE)objdump

LIBPATH			:= -lgcc


INCDIRS 		:= . \
				   minilzo_src 

				   			   
SRCDIRS			:= . \
				   minilzo_src 
				   
				   
INCLUDE			:= $(patsubst %, -I %, $(INCDIRS))

SFILES			:= $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
CFILES			:= $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))

SFILENDIR		:= $(notdir  $(SFILES))
CFILENDIR		:= $(notdir  $(CFILES))

SOBJS			:= $(patsubst %, build/%, $(SFILENDIR:.S=.o))
COBJS			:= $(patsubst %, build/%, $(CFILENDIR:.c=.o))
OBJS			:= $(SOBJS) $(COBJS)

VPATH			:= $(SRCDIRS)

.PHONY: clean
	
$(TARGET) : $(OBJS) $(BUILD_DIR)
	$(CC) -o $(TARGET) $(OBJS)

$(COBJS) : build/%.o : %.c $(BUILD_DIR)
	$(CC) -Wall -c $(INCLUDE) -o $@ $<

$(BUILD_DIR):
	mkdir $@

clean:
	rm -rf $(TARGET) $(COBJS) $(SOBJS)

	
